export default {
    // 计算星期几
    getWeekDate(day) {
        var weeks = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
        var week = weeks[day];
        return week;
    },
    fontSize(res){
        let clientHeight = window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;
        if(clientHeight <= 2560 && clientHeight >1080) {
          return res * (clientHeight/2560);
        }else if(clientHeight <= 1080) {
            return res * (1080/2560);
        }
    },
    //去除价格小数点后多余的0
    cutZero(val) {
        //拷贝一份 返回去掉零的新串
        val = val.toString();
        let newstr = val.toString(); //判断是否有效数
        if (val.indexOf(".") > -1) {
            //循环变量 小数部分长度
            var leng = val.length - val.indexOf(".") - 1; // //循环小数部分
            for (let i = leng; i > 0; i--) {
            //如果newstr末尾有0
            if (
                newstr.lastIndexOf("0") > -1 &&
                newstr.substr(newstr.length - 1, 1) == 0
            ) {
                var k = newstr.lastIndexOf("0"); //如果小数点后只有一个0 去掉小数点
                if (newstr.charAt(k - 1) == ".") {
                return newstr.substring(0, k - 1);
                } else {
                //否则 去掉一个0
                newstr = newstr.substring(0, k);
                }
            } else {
                //如果末尾没有0
                return newstr;
            }
            }
        }
        return val;
    },
    // 地理坐标转换成屏幕坐标
    _geoCoordsToScreenCoords(geoCoords) {
        var china_geometry_bounds = [73.4994136, 53.56097399999999, 61.2733963, 35.40335839999999];  // 西北的经纬度和经纬度跨度
        var point_x = Math.abs(geoCoords[0] - china_geometry_bounds[0]) / china_geometry_bounds[2] * this._containerWidth,
            point_y = Math.abs(geoCoords[1] - china_geometry_bounds[1]) / china_geometry_bounds[3] * this._containerHeight;
        return [point_x, point_y];
    }
}